home *** CD-ROM | disk | FTP | other *** search
- /* COPYA.C - COPY A FILE WITH GETC/PUTC */
- #include "stdio.h"
-
- main(argc,argv)
- int argc ;
- char *argv[] ;
- {
- FILE *in ,
- *out ;
- int c ;
- long n ;
-
- if( argc < 3 )
- { printf(" USAGE - copy2 input-file output-file \n");
- exit(1);
- }
-
- in = fopen(argv[1],"r");
- out = fopen(argv[2],"w");
- if( (in == NULL) || (out == NULL) )
- { printf(" Can't open a file");
- exit(0) ;
- }
-
- n = 0L ;
- c = getc(in) ;
- while( c != EOF )
- { n = n + 1 ;
- putc(c,out);
- c = getc(in) ;
- } ;
- fclose(in) ;
- fclose(out);
- printf(" %1d characters copied",n) ;
- }